/**
  * The various detais of the person playing
  *
  * @author "Brian MacCarthy","Owen Grogan";
  * @created "2007-03-04 Brian MacCarthy";
  * @revised "$Date: 2007-03-06 19:11:00 $"; 
  */

package exfist;

import java.awt.event.KeyEvent;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JComponent;

public class Player extends JComponent
{
	
	private String name;
	private int score;
	private Character player_char; //prob wont need this later
	private BufferedImage temp;
	private BufferedImage temp2;
	private int x,y,movecount;
	private State_Tree state;
	private Control_Node base_state;
	private Point p;
	SpriteCache sc=new SpriteCache();
	protected Player()
	{
		p = new Point(500,500);
		name = "player";
		this.setScore(0);
		state= new State_Tree();
		temp= sc.getSprite("Anims/Ryu/ryustance.gif");
		temp2= sc.getSprite("Anims/Ryu/walkf/ryuwalkf.gif");
		base_state = new Control_Node("base_state",temp,p);
		state = new State_Tree(base_state);
		x=150;
		y=400;
	}
	
	public BufferedImage getCurrentSprite(){
		if(movecount%15==0)
			return temp;
		else
			return temp2;
	}
		
	private String getPlayerName()
	{
		return name;
	}
	private int getScore()
	{
		return score;
	}
	private void setScore(int x)
	{
		score=x;
	}
	private void incScore(int x)
	{
		score+=x;
	}
	public int getX(){
		return x;
	}
	public int getY(){
		return y;
	}
	public void keyPressed(KeyEvent e) 
	{
		switch(e.getKeyCode())
		{
			case KeyEvent.VK_RIGHT : x=x+5;movecount++;break;
			case KeyEvent.VK_LEFT : x=x-5;movecount++;break;
		}
	}
	protected void setPlayerName(String new_name)
	{
		name=new_name;
	}
}
